import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import i18n from './lang' // internationalization
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import Antd from 'ant-design-vue'
// import 'ant-design-vue/dist/antd.css'
import 'ant-design-vue/dist/antd.less'


Vue.use(Antd)
Vue.prototype.$antdconfirm = Vue.prototype.$confirm
// markdown编辑器
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'

import 'github-markdown-css'

Vue.use(mavonEditor)


// 引入vue-amap
import VueAMap from 'vue-amap';

Vue.use(VueAMap);// 初始化vue-amap
VueAMap.initAMapApiLoader({
  key: 'ac03a7e5af288df59eb5bf2da2ce9cde',
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
  v: '1.4.4'
});

import * as filters from './filters' // global filters

import Storage from 'vue-ls'
import config from '@/settings'
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

Vue.use(Element, {
  size: Cookies.get('size') || 'small', // set element-ui default size  默认：medium
  i18n: (key, value) => i18n.t(key, value)
})

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

Vue.use(Storage, config.storageOptions)

// 图片大图预览
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'

Vue.use(Viewer)
Viewer.setDefaults({
  Options: {
    'inline': true,
    'button': true,
    'navbar': true,
    'title': true,
    'toolbar': true,
    'tooltip': true,
    'movable': true,
    'zoomable': true,
    'rotatable': true,
    'scalable': true,
    'transition': true,
    'fullscreen': true,
    'keyboard': true,
    'url': 'data-source'
  }
})

// 一键复制
import VueClipboard from 'vue-clipboard2'

Vue.use(VueClipboard)

// 懒加载
import VueLazyload from 'vue-lazyload'
import load_error from './assets/images/加载失败.png'
import load_img from './assets/images/load_img.gif'

Vue.use(VueLazyload, {
  error: load_error,
  loading: load_img
})

import tagCloud from 'v-tag-cloud'

Vue.use(tagCloud)

import hl from 'highlight.js' // 导入代码高亮文件
import 'highlight.js/styles/atom-one-dark.css' // 导入代码高亮样式

// 自定义一个代码高亮指令
Vue.directive('highlight', function (el) {
  const blocks = el.querySelectorAll('pre code')
  blocks.forEach((block) => {
    hl.highlightBlock(block)
  })
})


new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
